package com.heba.helper;

import android.app.Activity;
import android.content.Context;
import android.os.Build;

import com.heba.Cfg;
import com.heba.greenmulu.R;
import com.loopj.android.http.RequestParams;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.io.FileNotFoundException;

/**
 * MemberShipHelper
 * Created by shenghao on 2018/11/23.
 */
public class MemberShipHelper {

    private MembershipListener membershipListener;
    private HttpClientHelper client = new HttpClientHelper();

    public MemberShipHelper(MembershipListener membershipListener) {
        this.membershipListener = membershipListener;
    }

    /**
     * 设置回调接口
     *
     * @param membershipListener
     */
    public void setMembershipListener(MembershipListener membershipListener) {
        this.membershipListener = membershipListener;
    }

    /**
     * 邮箱登录
     *
     * @param context
     * @param email
     * @param password
     */
    public void emailLogin(Context context, String email, String password) {
        RequestParams params = new RequestParams();
        params.put("Email", email);
        params.put("Password", password);
        client.post(Cfg.BaseUrl + "/User/Login?", params, new JSONHttpHelper.JSONHttpResponseHandler(context) {
            @Override
            public void Success() {
                super.Success();
                try {
                    JSONObject json = new JSONObject(response.trim());
                    JSONObject jsonObject = json.getJSONObject("Result");
                    Cfg.saveLoginInfo(jsonObject);
                    if (membershipListener != null)
                        membershipListener.Success();
                } catch (Exception e) {
                    if (membershipListener != null)
                        membershipListener.Fail(error);
                }
            }

            @Override
            public void Failure() {
                super.Failure();
                if (membershipListener != null)
                    membershipListener.Fail(error);
            }
        });
    }

    /**
     * 邮箱注册
     *
     * @param context
     * @param email
     * @param password
     */
    public void emailSignup(Context context, String email, String password) {
        RequestParams params = new RequestParams();
        params.put("Email", email);
        params.put("Password", password);
        client.post(Cfg.BaseUrl + "/User/Register?", params, new JSONHttpHelper.JSONHttpResponseHandler(context) {
            @Override
            public void Success() {
                super.Success();
                try {
                    JSONObject json = new JSONObject(response.trim());
                    JSONObject jsonObject = json.getJSONObject("Result");
                    Cfg.change("UserID", jsonObject.getString("UserID"));
                    Cfg.change("SessionKey", jsonObject.getString("SessionKey"));
                    Cfg.change("NickName", jsonObject.getString("Nickname"));
                    Cfg.change("Icon", jsonObject.getString("Icon"));
                    Cfg.change("LastName", jsonObject.getString("LastName"));
                    Cfg.change("Sex", jsonObject.getString("Sex"));
                    Cfg.change("BirthYear", jsonObject.getString("BirthYear"));
                    Cfg.change("BirthMonth", jsonObject.getString("BirthMonth"));
                    Cfg.change("Address", jsonObject.getString("Address"));
                    Cfg.change("Addressen", jsonObject.getString("Addressen"));
                    Cfg.save();
                    if (membershipListener != null)
                        membershipListener.Success();
                } catch (Exception e) {
                    if (membershipListener != null)
                        membershipListener.Fail(error);
                }
            }

            @Override
            public void Failure() {
                super.Failure();
                if (membershipListener != null)
                    membershipListener.Fail(error);
            }
        });
    }

    /**
     * 新版邮箱注册
     *
     * @param context
     * @param pictureUrl
     * @param account
     * @param name
     * @param email
     * @param password
     */
    public void emailSignupNew(Context context, String pictureUrl, String account, String name, String email, String password,String DeviceToken) {
        RequestParams params = new RequestParams();

        params.put("PictureUrl", pictureUrl);
        params.put("Account", account);
        params.put("Nickname", name);
        params.put("Email", email);
        params.put("Password", password);
        params.put("DeviceToken",DeviceToken);
        client.post(Cfg.BaseUrl + "/User/mb_Register?", params, new JSONHttpHelper.JSONHttpResponseHandler(context) {
            @Override
            public void Success() {
                super.Success();
                try {
                    JSONObject json = new JSONObject(response.trim());
                    JSONObject jsonObject = json.getJSONObject("Result");
                    Cfg.change("UserID", jsonObject.getString("UserID"));
                    Cfg.change("SessionKey", jsonObject.getString("SessionKey"));
                    Cfg.change("Nickname", jsonObject.getString("Nickname"));
                    Cfg.change("Icon", jsonObject.getString("Icon"));
                    Cfg.change("Account", jsonObject.getString("Account"));
                    Cfg.change("Email", jsonObject.getString("Email"));
                    Cfg.change("AccountType",jsonObject.getString("AccountType"));
                    Cfg.save();
                    if (membershipListener != null)
                        membershipListener.Success();
                } catch (Exception e) {
                    if (membershipListener != null)
                        membershipListener.Fail(error);
                }
            }

            @Override
            public void Failure() {
                super.Failure();
                if (membershipListener != null)
                    membershipListener.Fail(error);
            }
        });
    }

    /**
     * 微信登陆
     * 获取的微信用户信息传递给服务器处理
     *
     * @param activity
     * @param openid
     * @param unionid
     * @param nickname
     */
    public void wechatLogin(final Activity activity, final String openid, final String unionid, String nickname, String headimgurl) {
        RequestParams params = new RequestParams();
        params.put("OpenId", openid);
        params.put("UnionId", unionid);
        params.put("NickName", nickname);
        params.put("HeadImgUrl", headimgurl);
        client.post(Cfg.BaseUrl + "/Wechat/Login?", params, new JSONHttpHelper.JSONHttpResponseHandler(activity) {
            @Override
            public void Success() {
                super.Success();
                try {
                    JSONObject json = new JSONObject(response.trim());
                    JSONObject jsonObject = json.getJSONObject("Result");
                    Cfg.saveLoginInfo(jsonObject);
                    if (membershipListener != null)
                        membershipListener.Success();
                } catch (Exception e) {
                    if (membershipListener != null)
                        membershipListener.Fail(error);
                }
            }

            @Override
            public void Failure() {
                super.Failure();
                if (membershipListener != null)
                    membershipListener.Fail(error);
            }
        });
    }

    /**
     * facebook登录
     *
     * @param activity
     * @param id
     * @param nickname
     * @param imageUrl
     */
    public void facebookLogin(final Activity activity, final String id, String nickname, String imageUrl) {
        RequestParams params = new RequestParams();
        params.put("FaceBookUserID", id);
        params.put("FaceBookName", nickname);
        params.put("HeadImgUrl", imageUrl);
        client.post(Cfg.BaseUrl + "/FaceBook/Login?", params, new JSONHttpHelper.JSONHttpResponseHandler(activity) {
            @Override
            public void Success() {
                super.Success();
                try {
                    JSONObject json = new JSONObject(response.trim());
                    JSONObject jsonObject = json.getJSONObject("Result");
                    Cfg.saveLoginInfo(jsonObject);
                    if (membershipListener != null)
                        membershipListener.Success();
                } catch (Exception e) {
                    if (membershipListener != null)
                        membershipListener.Fail(error);
                }
            }

            @Override
            public void Failure() {
                super.Failure();
                if (membershipListener != null)
                    membershipListener.Fail(error);
            }
        });
    }

    /**
     * 获取邮箱验证码
     *
     * @param context
     * @param email
     */
    public void getEmailCode(Context context, String email) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Email", email);
        params.put("Leng", Cfg.Leng);
        client.get(Cfg.BaseUrl + "/User/SendEmailVerifyCode", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 重置密码
     *
     * @param context
     * @param email
     * @param password
     * @param validateCode
     */
    public void resetEmailPassword(Context context, String email, String password, String validateCode) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Email", email);
        params.put("Password", password);
        params.put("ValidateCode", validateCode);
        client.get(Cfg.BaseUrl + "/User/EditPassword", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 绑定微信
     *
     * @param context
     * @param openID
     * @param unionID
     */
    public void bindWechat(Context context, String openID, String unionID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("OpenID", openID);
        params.put("UnionID", unionID);
        client.get(Cfg.BaseUrl + "/User/BindWechat", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 解绑微信
     *
     * @param context
     */
    public void unbundWechat(Context context) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        client.get(Cfg.BaseUrl + "/User/UnbundWechat", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 绑定facebook
     *
     * @param context
     * @param facebookUserID
     */
    public void bindFacebook(Context context, String facebookUserID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("FaceBookUserID", facebookUserID);
        client.get(Cfg.BaseUrl + "/User/BindFacebook", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 解绑facebook
     *
     * @param context
     */
    public void unbundFacebook(Context context) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        client.get(Cfg.BaseUrl + "/User/UnbundFacebook", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 绑定邮箱
     *
     * @param context
     * @param email
     */
    public void bindEmail(Context context, String email) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Email", email);
        client.get(Cfg.BaseUrl + "/User/BindEmail", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 获取用户基本信息
     *
     * @param context
     */
    public void getUserInfo(Context context) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        client.post(Cfg.BaseUrl + "/User/GetUserInfo?", params, new JSONHttpHelper.JSONHttpResponseHandler(context) {
            @Override
            public void Success() {
                super.Success();
                try {
                    JSONObject json = new JSONObject(response.trim());
                    JSONObject jsonObject = json.getJSONObject("Result");
                    Cfg.change("UserID", jsonObject.getString("UserID"));
                    Cfg.change("NickName", jsonObject.getString("Nickname"));
                    Cfg.change("Icon", jsonObject.getString("Icon"));
                    Cfg.change("LastName", jsonObject.getString("LastName"));
                    Cfg.change("Sex", jsonObject.getString("Gender"));
                    Cfg.change("BirthYear", jsonObject.getString("BirthYear"));
                    Cfg.change("BirthMonth", jsonObject.getString("BirthMonth"));
                    Cfg.change("Address", jsonObject.getString("Address"));
                    Cfg.change("Addressen", jsonObject.getString("Addressen"));
                    Cfg.change("Email", jsonObject.getString("Email"));
                    Cfg.change("Account", jsonObject.getString("Account"));
                    Cfg.change("Openid", jsonObject.getString("Openid"));
                    Cfg.change("UnionID", jsonObject.getString("UnionID"));
                    Cfg.change("FaceBookUserID", jsonObject.getString("FaceBookUserID"));
                    Cfg.save();
                    if (membershipListener != null)
                        membershipListener.Success();
                } catch (Exception e) {
                    if (membershipListener != null)
                        membershipListener.Fail(error);
                }
            }

            @Override
            public void Failure() {
                super.Failure();
                if (membershipListener != null)
                    membershipListener.Fail(error);
            }
        });
    }

    /**
     * 更新用户信息
     *
     * @param context
     * @param headerUrl
     * @param first_name
     * @param last_name
     * @param sex
     * @param birth_month
     * @param birth_year
     * @param address
     * @param addressEN
     */
    public void setUserInfo(Context context, String headerUrl, String first_name, String last_name, int sex, int birth_month, int birth_year, String address, String addressEN) {
        RequestParams params = new RequestParams();
        client.setUseLogin(true);
        params.put("Leng", Cfg.Leng);
        params.put("PictureUrl", headerUrl);
        params.put("Nickname", first_name);
        params.put("LastName", last_name);
        params.put("Sex", sex);
        params.put("BirthMonth", birth_month);
        params.put("BirthYear", birth_year);
        params.put("Address", address);
        params.put("Addressen", addressEN);
        client.post(Cfg.BaseUrl + "/User/SetUserInfo?", params, new JSONHttpHelper.JSONHttpResponseHandler(context) {
            @Override
            public void Success() {
                super.Success();
                if (membershipListener != null)
                    membershipListener.Success();
            }

            @Override
            public void Failure() {
                super.Failure();
                if (membershipListener != null)
                    membershipListener.Fail(error);
            }
        });
    }

    /**
     * facebook、wechat完善信息
     *
     * @param context
     * @param pictureUrl
     * @param account
     * @param name
     * @param email
     * @param password
     */
    public void setUserInfoNew(Context context, String pictureUrl, String account, String name, String email, String password,String deviceToken) {
        RequestParams params = new RequestParams();
        client.setUseLogin(true);
        params.put("Leng", Cfg.Leng);
        params.put("PictureUrl", pictureUrl);
        params.put("Nickname", name);
        params.put("Account", account);
        params.put("Email", email);
        params.put("Password", password);
        params.put("DeviceToken",deviceToken);
        client.post(Cfg.BaseUrl + "/User/mb_SetUserInfo?", params, new JSONHttpHelper.JSONHttpResponseHandler(context) {
            @Override
            public void Success() {
                super.Success();
                if (membershipListener != null)
                    membershipListener.Success();
            }

            @Override
            public void Failure() {
                super.Failure();
                if (membershipListener != null)
                    membershipListener.Fail(error);
            }
        });
    }

    /**
     * 编辑用户信息
     *
     * @param context
     * @param headerUrl
     * @param account
     * @param nickName
     * @param profile
     * @param webside
     * @param email
     * @param mobile
     * @param sex
     * @param address
     * @param addressEN
     */
    public void setUserInfoV1(Context context, String headerUrl, String account, String nickName, String profile,
                              String webside, String email, String mobile, int sex, String address, String addressEN,String bannerUrl) {
        RequestParams params = new RequestParams();
        client.setUseLogin(true);
        params.put("PictureUrl", headerUrl);
        params.put("Account", account);
        params.put("Nickname", nickName);
        params.put("Profile", profile);
        params.put("Webside", webside);
        params.put("Email", email);
        params.put("Mobile", mobile);
        params.put("Sex", sex);
        params.put("Address", address);
        params.put("BannerUrl",bannerUrl);
        params.put("Addressen", addressEN);
        client.post(Cfg.BaseUrl + "/User/SetUserInfoV1?", params, new JSONHttpHelper.JSONHttpResponseHandler(context) {
            @Override
            public void Success() {
                super.Success();
                if (membershipListener != null)
                    membershipListener.Success();
            }

            @Override
            public void Failure() {
                super.Failure();
                if (membershipListener != null)
                    membershipListener.Fail(error);
            }
        });
    }
    public void setBusinessInfoV1(Context context, String headerUrl, String account, String nickName, String profile,
                              String webside, String email, String mobile, int sex, String address, String addressEN,String bannerUrl) {
        RequestParams params = new RequestParams();
        client.setUseLogin(true);
        params.put("PictureUrl", headerUrl);
        params.put("Account", account);
        params.put("Nickname", nickName);
        params.put("Profile", profile);
        params.put("Webside", webside);
        params.put("Email", email);
        params.put("Mobile", mobile);
        params.put("Sex", sex);
        params.put("Address", address);
        params.put("Addressen", addressEN);
        params.put("BannerUrl",bannerUrl);
        client.post(Cfg.BaseUrl + "/User/SetUserInfoV1?", params, new JSONHttpHelper.JSONHttpResponseHandler(context) {
            @Override
            public void Success() {
                super.Success();
                if (membershipListener != null)
                    membershipListener.Success();
            }

            @Override
            public void Failure() {
                super.Failure();
                if (membershipListener != null)
                    membershipListener.Fail(error);
            }
        });
    }
    /**
     *@"Name",@"Nick",@"Address",@"Email",@"Phone",@"ImageUrls"
     */
    public void registerBusinessAccount(Context context,String name,String nick,String address,String email,String phone,String imageUrls,int Type)
    {
        RequestParams params = new RequestParams();
        client.setUseLogin(true);
        params.put("Name", name);
        params.put("Nick", nick);
        params.put("Address", address);
        params.put("Email", email);
        params.put("Phone", phone);
        params.put("ImageUrls", imageUrls);
        params.put("Type",Type);
        client.post("/User/ApplyBusinessAccount?", params, new JSONHttpHelper.JSONHttpResponseHandler(context) {
            @Override
            public void Success() {
                super.Success();
                try {
                    if (membershipListener != null)
                        membershipListener.Success();
                } catch (Exception e) {
                    if (membershipListener != null)
                        membershipListener.Fail(error);
                }
            }

            @Override
            public void Failure() {
                if (membershipListener != null)
                    membershipListener.Fail(error);
            }
        });
    }
    /**
     * 存储设备信息到服务器
     *
     * @param context
     * @param userID
     * @param registrationID
     * @param timeLimit
     */
    public void saveDevice(Context context, String userID, String registrationID, String timeLimit) {
        RequestParams params = new RequestParams();
        client.setUseLogin(false);
        params.put("UserID", userID);
        params.put("DeviceToken", registrationID);
        params.put("AppVersion", Cfg.appVersionName);
        params.put("DeviceName", Build.MODEL);
        params.put("DeviceVersion", Build.VERSION.RELEASE);
        params.put("TimeLimit", timeLimit);
        params.put("Platform", "android");
        client.post("/Push/SaveDevice?", params, new JSONHttpHelper.JSONHttpResponseHandler(context) {
            @Override
            public void Success() {
                super.Success();
                try {
                    if (membershipListener != null)
                        membershipListener.Success();
                } catch (Exception e) {
                    if (membershipListener != null)
                        membershipListener.Fail(error);
                }
            }

            @Override
            public void Failure() {
                if (membershipListener != null)
                    membershipListener.Fail(error);
            }
        });
    }

    /**
     * 收藏文章
     *
     * @param context
     * @param articleID
     */
    public void collectArticle(Context context, String articleID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("ArticleID", articleID);
        client.get(Cfg.BaseUrl + "/Article/Collect", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 取消收藏文章
     *
     * @param context
     * @param articleID
     */
    public void uncollectArticle(Context context, String articleID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("ArticleID", articleID);
        client.get(Cfg.BaseUrl + "/Article/UnCollect", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 收藏产品
     *
     * @param context
     * @param productID
     */
    public void collectProduct(Context context, String productID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("ProductID", productID);
        client.get(Cfg.BaseUrl + "/Product/Collect", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 取消收藏产品
     *
     * @param context
     * @param productID
     */
    public void uncollectProduct(Context context, String productID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("ProductID", productID);
        client.get(Cfg.BaseUrl + "/Product/UnCollect", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 刪除掃碼歷史
     *
     * @param context
     * @param historyID
     */
    public void deleteHistoryProduct(Context context, String historyID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("HistoryID", historyID);
        client.get(Cfg.BaseUrl + "/Product/DeleteHistory", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 扫描条形码
     *
     * @param context
     * @param barCode
     */
    public void getBarCodeScanResult(Context context, String barCode) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Barcode", barCode);
        client.get(Cfg.BaseUrl + "/Product/QRanalysis", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        try {
                            JSONObject json = new JSONObject(response.trim());
                            JSONObject jsonObject = json.getJSONObject("Result");
                            Cfg.isProduct = jsonObject.getString("IsProduct").equals("1") ? true : false;
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 产品报告错误提交
     *
     * @param context
     * @param productID
     * @param barCode
     * @param brandName
     * @param productName
     * @param servingValuePer
     * @param ingredients
     * @param remark1
     * @param remark2
     * @param photoJson
     */
    public void reportProduct(Context context, String productID, String barCode, String brandName, String productName, String servingValuePer,
                              String ingredients, String remark1, String remark2, String photoJson) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("ProductID", productID);
        params.put("Barcode", barCode);
        params.put("BrandName", brandName);
        params.put("ProductName", productName);
        params.put("ServingValuePer", servingValuePer);
        params.put("Ingredients", ingredients);
        params.put("Remark1", remark1);
        params.put("Remark2", remark2);
        params.put("PhotoJson", photoJson);
        client.get(Cfg.BaseUrl + "/Product/ReportErrorPost", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 添加产品
     *
     * @param context
     * @param barCode
     * @param brandName
     * @param productName
     * @param servingValuePer
     * @param ingredients
     * @param remark1
     * @param remark2
     * @param photoJson
     */
    public void addProduct(Context context, String barCode, String brandName, String productName, String servingValuePer,
                           String ingredients, String remark1, String remark2, String photoJson) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("Barcode", barCode);
        params.put("BrandName", brandName);
        params.put("ProductName", productName);
        params.put("ServingValuePer", servingValuePer);
        params.put("Ingredients", ingredients);
        params.put("Remark1", remark1);
        params.put("Remark2", remark2);
        params.put("PhotoJson", photoJson);
        client.get(Cfg.BaseUrl + "/Product/AddProduct", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 上傳日記
     *
     * @param context
     * @param content   內容
     * @param type      0：表示產品評價  1：表示新增日記
     * @param productID 產品ID
     * @param star      產品星級
     * @param photoJson 圖片json
     * @param tagJson   話題json
     */
    public void uploadDiaryContent(Context context, String content, int type, String productID, int star, String photoJson, String tagJson, String userJson,String place,String location,double lat,double lng) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("Content", content);
        params.put("Type", type);
        params.put("ProductID", productID);
        params.put("Star", star);
        params.put("PathJson", photoJson);
        params.put("TalkJson", tagJson);
        params.put("UserJson",userJson);
        params.put("Place",place);
        params.put("Location",location);
        params.put("Lat",lat);
        params.put("Lng",lng);
        client.post(Cfg.BaseUrl + "/Diary/AddDiary", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 點讚日記
     *
     * @param context
     * @param diaryID 日記id
     * @param type    0表示點讚 1表示取消點讚
     */
    public void diaryLike(Context context, String diaryID, int type) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("DiaryID", diaryID);
        params.put("Type", type);
        client.post(Cfg.BaseUrl + "/Diary/Like", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 增加地址
     * @param context
     * @param AddressId
     * @param Lng
     * @param Lat
     * @param Unit
     * @param Floor
     * @param Building
     * @param Estate
     * @param Street
     * @param District
     * @param Phone
     */
    public void addNewAddress(Context context, int AddressId, double Lng,double Lat,String Unit,String Floor,String Building,String Estate,String Street,String District,String Phone,String type) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("AddressId",AddressId);
        params.put("Lng",Lng);
        params.put("Lat",Lat);
        params.put("Unit",Unit);
        params.put("Floor",Floor);
        params.put("Building",Building);
        params.put("Estate",Estate);
        params.put("Street",Street);
        params.put("District",District);
        params.put("Phone",Phone);
        params.put("Type",type);
        client.post(Cfg.BaseUrl + "/User/SaveUserAddressInfo", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }
    /**
     * 傳送信息
     *
     * @param context
     * @param resourceID
     * @param type
     * @param toUserID
     */
    public void sendMessage(Context context, String resourceID, int type, String toUserID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("ResourceID", resourceID);
        params.put("ToUserID", toUserID);
        params.put("Type", type);
        client.post(Cfg.BaseUrl + "/Transfer/Send", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 聊天详情页 传送文字
     *
     * @param context
     * @param message
     * @param toUserID
     */
    public void sendTextMessage(Context context, String message, String toUserID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("ResourceID", 0);
        params.put("Message", message);
        params.put("ToUserID", toUserID);
        params.put("Type", 2);
        client.post(Cfg.BaseUrl + "/Transfer/Send", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 添加日記評論以及回復用戶留言
     *
     * @param context
     * @param diaryID
     * @param type       類型 0表示給日記留言 1表示回復用戶
     * @param message
     * @param toUserID
     * @param feedbackID 留言id type=1時必填
     */
    public void addFeedback(Context context, String diaryID, int type, String message, String toUserID, String feedbackID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("DiaryID", diaryID);
        params.put("Message", message);
        params.put("FeedbackID", feedbackID);
        params.put("ToUserID", toUserID);
        params.put("Type", type);
        client.post(Cfg.BaseUrl + "/Diary/AddFeedback", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 关注用户
     *
     * @param context
     * @param toUserID 需要关注的用户ID
     */
    public void followUser(Context context, String toUserID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("ToUserID", toUserID);
        client.post(Cfg.BaseUrl + "/User/Follow", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 取消关注用户
     *
     * @param context
     * @param toUserID
     */
    public void unFollowUser(Context context, String toUserID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("ToUserID", toUserID);
        client.post(Cfg.BaseUrl + "/User/CancelFollow", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * @param context
     * @param hashtagID
     * @param type
     */
    public void followHashTag(Context context, String hashtagID, String type) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("HashtagID", hashtagID);
        params.put("Type", type);
        client.post(Cfg.BaseUrl + "/Diary/FollowHashtag", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 收藏日記
     *
     * @param context
     * @param diaryID
     */
    public void collectDiary(Context context, String diaryID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("DiaryID", diaryID);
        params.put("Type", 2);
        client.post(Cfg.BaseUrl + "/User/DiaryStatus", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 删除日记
     *
     * @param context
     * @param diaryID
     */
    public void deleteDiary(Context context, String diaryID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("DiaryID", diaryID);
        client.post(Cfg.BaseUrl + "/User/CancelDiary", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 隱藏日記
     *
     * @param context
     * @param diaryID
     */
    public void hiddenDiary(Context context, String diaryID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("DiaryID", diaryID);
        params.put("Type", 1);
        client.post(Cfg.BaseUrl + "/User/DiaryStatus", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 移除標籤
     *
     * @param context
     * @param diaryID
     */
    public void removeTag(Context context, String diaryID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("DiaryID", diaryID);
        params.put("Type", 3);
        client.post(Cfg.BaseUrl + "/User/DiaryStatus", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 舉報賬戶或日記
     *
     * @param context
     * @param type     1表示舉報賬戶 2表示舉報日記
     * @param reportID 賬戶ID或者日記ID
     * @param content  舉報內容
     */
    public void reportContent(Context context, int type, String reportID, String content) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("Type", type);
        params.put("Content", content);
        params.put("ResourceID", reportID);
        client.post(Cfg.BaseUrl + "/User/Report", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 丢弃产品
     *
     * @param context
     * @param select1
     * @param select2
     * @param select3
     * @param select4
     * @param remark
     */
    public void discardProduct(Context context, boolean select1, boolean select2, boolean select3, boolean select4, String remark) {
        StringBuffer sb = new StringBuffer();
        if (select1) {
            sb.append(context.getResources().getString(R.string.choice1));
            sb.append(",");
        }
        if (select2) {
            sb.append(context.getResources().getString(R.string.choice2));
            sb.append(",");
        }
        if (select3) {
            sb.append(context.getResources().getString(R.string.choice3));
            sb.append(",");
        }
        if (select4) {
            sb.append(context.getResources().getString(R.string.choice1));
            sb.append(",");
        }
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("WhyDiscard", sb.deleteCharAt(sb.length() - 1));
        params.put("Remark", remark);
        client.get(Cfg.BaseUrl + "/Product/Discard", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 检查app更新
     *
     * @param activity
     */
    public void checkAppUpdate(final Activity activity) {
        RequestParams params = new RequestParams();
        params.put("PlatformID", 1);
        client.post(Cfg.BaseUrl + "/Config/GetAppConfig?", params, new JSONHttpHelper.JSONHttpResponseHandler(activity) {
            @Override
            public void Success() {
                super.Success();
                try {
                    JSONObject json = new JSONObject(response.trim());
                    JSONObject jsonObject = json.getJSONObject("Result");
                    Cfg.change("AppVer", (float) jsonObject.getDouble("Ver"));
                    Cfg.save();
                    if (membershipListener != null)
                        membershipListener.Success();
                } catch (Exception e) {
                    if (membershipListener != null)
                        membershipListener.Fail(error);
                }
            }

            @Override
            public void Failure() {
                super.Failure();
                if (membershipListener != null)
                    membershipListener.Fail(error);
            }
        });
    }

    /**
     * 删除留言
     *
     * @param context
     * @param diaryID
     * @param feedbackID
     */
    public void deleteMessage(Context context, String diaryID, String feedbackID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("DiaryID", diaryID);
        params.put("FeedbackID", feedbackID);
        client.post(Cfg.BaseUrl + "/Diary/DeleteFeedback", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 最近搜索记录处理
     *
     * @param context
     * @param handle   Add操作时传递ValueID  Delete操作时传递recentID
     * @param type     填入（Category：分類，Product：產品，Feature：特點，Account：賬戶，Hashtag：話題）
     * @param recentID 记录ID
     * @param valueID  根据type取相对应的ID
     */
    public void handleRecentLog(Context context, String handle, String type, int recentID, int valueID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("Handle", handle);
        params.put("Type", type);
        params.put("RecentID", recentID);
        params.put("ValueID", valueID);
        client.post(Cfg.BaseUrl + "/Event/HandleRecentLog", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }

    /**
     * 上传图片
     *
     * @param context
     * @param uploadPath
     */
    public void uploadImage(Context context, String uploadPath) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        try {
            params.put("File", new File(uploadPath));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        client.postFile(context, Cfg.BaseUrl + "/Upload/SaveImage", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        try {
                            JSONObject json = new JSONObject(response.trim());
                            JSONObject o = json.getJSONObject("Result");
                            Cfg.uploadImageUrl = o.getString("ImageUrl");
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }
    /**
     * 點讚日記
     *
     * @param context
     * @param addressID 地址ID
     *
     */
    public void selectAddress(Context context, int addressID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("AddressId", addressID);

        client.post(Cfg.BaseUrl + "/User/SetUserAddressInfo", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }
    public void selectShopAddress(Context context, int addressID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("Leng", Cfg.Leng);
        params.put("AddressId", addressID);
        params.put("Type","1");

        client.post(Cfg.BaseUrl + "/User/SetUserAddressInfo", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }
    public void CancelBlockUser(Context context, String userID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("BuddyID", userID);
        params.put("UserID",Cfg.UserID);

        client.post(Cfg.BaseUrl + "/Blacklist/Remove", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }
    public void BlockUser(Context context, String userID) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        params.put("BuddyID", userID);
        params.put("UserID",Cfg.UserID);

        client.post(Cfg.BaseUrl + "/Blacklist/Add", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }
    /**
     * 上传图片
     *
     * @param context
     * @param uploadPath
     */
    public void uploadSamImage(Context context, String uploadPath) {
        client.setUseLogin(true);
        RequestParams params = new RequestParams();
        try {
            params.put("File", new File(uploadPath));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        client.postFile(context, Cfg.BaseUrl + "/upload/saveimage", params,
                new JSONHttpHelper.JSONHttpResponseHandler(context) {

                    @Override
                    public void Success() {
                        // TODO Auto-generated method stub
                        super.Success();
                        try {
                            JSONObject json = new JSONObject(response.trim());
                            JSONObject o = json.getJSONObject("Result");
                            if (membershipListener != null)
                            membershipListener.SamSuccess(o.getString("ImageUrl"));
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                        if (membershipListener != null)
                            membershipListener.Success();
                    }

                    public void Failure() {
                        super.Failure();
                        if (membershipListener != null)
                            membershipListener.Fail(error);
                    }

                });
    }
    /**
     * 检查用户是否登陆
     */
    public static boolean isLogin() {
        return !Cfg.UserID.isEmpty() && !Cfg.SessionKey.isEmpty() && !Cfg.Email.isEmpty();
    }

    /**
     * 用户登出
     */
    public static void logOut() {
        Cfg.change("UserID", "");
        Cfg.change("SessionKey", "");
        Cfg.change("NickName", "");
        Cfg.change("Icon", "");
        Cfg.change("LastName", "");
        Cfg.change("BirthYear", "");
        Cfg.change("Email", "");
        Cfg.change("Account", "");
        Cfg.save();
    }

    /**
     * interface 回调接口
     */
    public interface MembershipListener {

        void Success();
        void Fail(String error);
        default void SamSuccess(String imageUrl){};
    }

}
